
require 'View/UIBase/UIBase'
UIInvasionReward = UIBase.New(PanelResNames.UIInvasionReward);

function UIInvasionReward.Init(func)
    UIBase.Init(UIInvasionReward, func);
end

--定义控件
function UIInvasionReward:OnCreate()
    self.rewardList=self:GetChild("list")
    self.rewardList.itemRenderer=function(index,obj)
        self:RefreshRewardItem(index+1,obj)
    end
    self.rewardList:SetVirtual()
    self.closeBtn=self:GetChild("bgClose")
    self:addEvent();
end
function UIInvasionReward:OnEnable()
    self:Refresh()
end

function UIInvasionReward:OnDisable()

end

function UIInvasionReward:OnDestroy()

end

-------------------------------function--------------------------------------
function UIInvasionReward:addEvent()
    self:RegisterOnClick(self.closeBtn,self.OnClickClose)
end
function UIInvasionReward:Refresh()
    local teamData=InvasionHandler.teamData
    local rewardTable=G.dataTable["t_collocationreward"]
    self.rewards=logicMgr.InvasionManager.getInvasionRewards(InvasionHandler.GetMyBossLv()-1)
    self.rewardList.numItems=0
    self.rewardList.numItems=#self.rewards
end

function UIInvasionReward:OnClickClose()
    self:OnBack()
end
function UIInvasionReward:RefreshRewardItem(index,obj)
    local data=self.rewards[index]
    local title=obj:GetChild("title")
    title.text=string.format(getLanguage("InvasionNextReward"),data.f_CollocationId)
    local rewardList=obj:GetChild("rewardList")
    logicMgr.CostManager.RefreshItemList(rewardList, decodeJsonStrToTabel(data.f_CollocationReward))
end
return UIInvasionReward;